package main

import "github.com/gin-gonic/gin"

func NoLogMiddleware() gin.HandlerFunc {
	return gin.LoggerWithConfig(gin.LoggerConfig{
		Skip: func(c *gin.Context) bool {
			// 检查当前路由是否在排除列表中
			if shouldExclude(c.Request.URL.Path) {
				return true
			}
			return false
		},
	})
}

// 将健康检查的路由排除日志,避免频繁打印
func shouldExclude(path string) bool {
	excludePaths := []string{"/health"}
	for _, p := range excludePaths {
		if path == p {
			return true
		}
	}
	return false
}
